package org.example.scoredata;

import org.example.ConnectDatabase;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Score extends ConnectDatabase{
    String s_ID;
    String name;



    int num , score;
    public List<Integer> h_score=new ArrayList<Integer>();

    public void search(String id){
        new ConnectDatabase();
        Statement sql;
        ResultSet rs;
        String str = "select * from historyscore where id = '" + id +"'";
        try {
            sql = con.createStatement();
            rs = sql.executeQuery(str);
            while (rs.next()) {
                int score = rs.getInt(3);
                h_score.add(score);
            }
            con.close();
        }catch (SQLException ignored){
            System.out.println("out");
        }
    }
    public int count(){
        new ConnectDatabase();
        Statement sql;
        ResultSet rs;
        String str = "select * from historyscore";
        int imf = 0;
        try {
            sql = con.createStatement();
            rs = sql.executeQuery(str);
            while (rs.next()) {
                imf ++;
            }
            con.close();
        }catch (SQLException ignored){
            System.out.println("chuck");
        }
        return imf;
    }


    public int getScore() {
        return score;
    }

    public String getS_ID() {
        return s_ID;
    }

    public void setS_ID(String s_ID) {
        this.s_ID = s_ID;
    }

    public void setNum() {
        this.num = count();
    }

    public void setScore(int score) {
        this.score = score;
    }

    public int getNum() {
        return this.num;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
